1 19:09:14
<template id="table1">
  <div>

    <table border="1">
      <tr>
        <th>编号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>电话</th>
        <th>邮件</th>
        <th>密码</th>
        <th>身份证</th>
        <th>状态</th>
        <th>操作</th>
      </tr>
      <tr v-for="(index) in list">
        <td v-for="(value) in index">{{value}}</td>
        <td> <button @click="del(index.id)">删除</button>/
          <button @click="update(index)">修改</button>
        </td>
      </tr>
    </table>
    <div>
      <form>
        id:<input  v-model="fuser.id" /><br>
        姓名: <input v-model="fuser.name"/><br>
        密码:<input v-model="fuser.password"><br>
        <button type="submit" @click="add()">提交</button>
      </form>
    </div>

    <div>
      <form>
        id:<input  v-model="fuser.id" /><br>
        姓名: <input v-model="fuser.name"/><br>
        密码:<input v-model="fuser.password"><br>
        <button type="submit" @click="upd()">提交</button>
      </form>
    </div>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  name: 'FuserManager',
  data () {
    return {
      list: [],
      fuser:{id:"",name:"",password:""},
      fuser1:{id:"",name:"",sex:"",phone:"",mail:"",idnumber:"",state:"",password:""},
      fuser2:{name:"",sex:"",phone:"",mail:"",idnumber:"",state:"",password:""},
    }
  },
  components:{
    "table1":{
      template:"table1",
      props:{
        list:[],
        title:""
      }
    }
  },
  created() {
    this.$http.post('/fuser/select').then(data=>{
      this.list = data;
    })
  },
  methods:{
    update(item){
      this.fuser.id=item.id;
      this.fuser.name=item.name;
      this.fuser.password=item.password;
    },
    del(id){
     // alert(id);
      // var params = new URLSearchParams();
      // params.append('id', '70');
      var f = new FormData()
      f.append('id', id)

      axios.post("http://localhost:2003/fuser/delete",f);
      //$.post("http://localhost:8080/texture/select");
      window.location.reload();
    },
    add(){
      this.$http.post("/fuser/insert", this.fuser).then(add=>{
        //alert(add);
        if(add>0){
          alert("添加成功");
          window.location.reload();
        }else{
          alert("添加失败")
        }
      })
    },
    upd(){
      this.$http.post("/fuser/update",this.fuser).then(add=>{
        //alert(add);
        if(add>0){
          alert("修改成功");
          window.location.reload();
        }else{
          alert("修改失败")
        }
      });
    },
  }
}
</script>

<style scoped>

</style>
